<?php
//+-----------------------
//|question控制器
//+-----------------------
class QuestionAction extends PublicAction{
	public function  index(){
		
		
	}
	//获得商品咨询列表
	public function getQuestionList(){
		if (empty($_GET["id"])) JSON(0,"请提供商品ID",0);
		$question=D("Question");
		
		//查询条件
		$where=array(
				"id_value"=>intval($_GET["id"]),
				"question_type"=>intval($_GET["type"]),
				"status"=>1,
				"parent_id"=>0
				);
		
		//普通查询 
		if($_GET["type"]==0){
			$where["question_type"]=array("egt",0);
			
		}
		if(!empty($_GET["keyword"])){
			$where.=" and ()";
			JSON(0,"暂时不支持搜索",0);;
			exit(0);
		}
		$count=$question->where($where)->count();
		
		
		import("@.Util.Page");
		
		$Page       = new Page($count,empty($_GET["number"])?5:intval($_GET["number"]));
		
		$Page->setConfig('theme',' %linkPage%%downPage% ');
		$show       = $Page->show();
		$rows=$question->where($where)->order("add_time desc")->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign("rows",$rows);
		$this->assign("show",$show);
		
		if (!empty($_GET["data_type"])){
			JSON($rows,"数据获取成功",1);
		}
		
		if (empty($_GET["data_type"])){
			$html=$this->fetch();
			$data["html"]=dotran($html);
			JSON($data,"数据获取成功",1);
		}else{
			$this->display();
		}
		
	}
	
	
	
}
?>